
import {match} from '../api/troops'
export const mactchInterval = {
  created () {
    let matchInterId = setInterval(() => {
      let params = {
        number: localStorage.getItem('number'),
        firendSex: null
      }
      match(params).then(data => {
        // 匹配成功后
        if (data.error === 0) {
          localStorage.setItem('firendSex', 0)
          this.$router.push({path: 'troops', query: {troopsId: data.data.troops_number}})
        }
      }).catch(e => {
        console.log(e.data)
      })
    }, 2500)
    sessionStorage.setItem('matchInterId', matchInterId)
  }
}
